import {createBrowserRouter, Link} from 'react-router-dom'
import {ErrorBlock} from 'antd-mobile'
import App from '../App'

const routes=createBrowserRouter([
    {
        path:'/',
        element:<App/>,
        children:[
            {
                path:'home',
                async lazy(){
                    const {default:Home,loader}=await import('../pages/home/Index')
                    return{
                        element:<Home/>,
                        loader
                    }
                }
            },
            {
                path:'todo',
                async lazy(){
                    const {default:Todo,loader}=await import('../pages/todo/Index')
                    return{
                        element:<Todo/>,
                        loader
                    }
                }
            },
            {
                path:'message',
                async lazy(){
                    const {default:Message,loader}=await import('../pages/message/Index')
                    return{
                        element:<Message/>,
                        loader
                    }
                }
            },
            {
                path:'my',
                async lazy(){
                    const {default:My,loader}=await import('../pages/my/Index')
                    return{
                        element:<My/>,
                        loader
                    }
                }
            },
            
        ]
    },
    {
        path:'*',
        element:(<ErrorBlock fullPage description={<Link to='/home'>返回首页</Link>}></ErrorBlock>)
    }
])
export default routes;